<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

/**
 * Class 订单支付异步邮件通知
 * @package App\Jobs
 */
class OrderPayEmailNotify implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $email;
    protected $order_sn;
    protected $nick_name;

    public function __construct($email,$nick_name,$order_sn)
    {
        $this->email = $email;
        $this->order_sn = $order_sn;
        $this->nick_name = $nick_name;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
    	$content = [
    		'order_sn'=>$this->order_sn,
			'username'=>$this->nick_name,
		];

        \Mail::send('email_tpl.order_email',$content,function ($message){
			$message->to($this->email)->subject('【订单支付成功】您的订单支付成功');
		});
    }
}
